package ru.mcfr.oxygen.framework.operations.table;

import ro.sync.ecss.extensions.api.*;
import ro.sync.ecss.extensions.api.access.AuthorTableAccess;
import ro.sync.ecss.extensions.api.node.AuthorNode;

import javax.swing.text.BadLocationException;

/**
 * Created by IntelliJ IDEA.
 * User: ws
 * Date: 11.03.11
 * Time: 12:25
 * To change this template use File | Settings | File Templates.
 */
public class DeleteCellOperation implements AuthorOperation{
    public void doOperation(AuthorAccess authorAccess, ArgumentsMap argumentsMap) throws IllegalArgumentException, AuthorOperationException {
        AuthorDocumentController controller = authorAccess.getDocumentController();
        AuthorSchemaManager manager = authorAccess.getDocumentController().getAuthorSchemaManager();
        AuthorTableAccess tableContainer = authorAccess.getTableAccess();
        int currentPosition = authorAccess.getEditorAccess().getCaretOffset();
        try {
            AuthorNode seldNode = controller.getNodeAtOffset(currentPosition);
            while (!seldNode.getName().equals("ячейка"))
                seldNode = seldNode.getParent();
            controller.deleteNode(seldNode);
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
    }

    public ArgumentDescriptor[] getArguments() {
        return new ArgumentDescriptor[0];
    }

    public String getDescription() {
        return null;
    }
}
